<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<script src="./jQuery/jquery-1.8.0.js"></script>
		<script src="util.js"></script>
		<link rel="stylesheet" type="text/css" href="style.css" />
		<title>项目管理系统：登录</title>
	</head>
	<body class='login'>
		<div id="login">
			<h1>项目管理系统登录</h1>
			<table>
				<tr>
					<td class="caption">用户名</td>
					<td class="input"><input name="name" type="text" maxlength="20" autocomplete='off'></td>
				</tr>
				<tr>
					<td class="caption">密&nbsp;&nbsp;&nbsp;码</td>
					<td class="input"><input name="pwd" type="password" maxlength="18"></td>
				</tr>
				<tr>
					<td class="caption"><button class='button loginBtn' onclick="return check();">登录</button></td>
					<td class="caption"><a href="register.php">注册</a></td>
				</tr>
			</table>
		</div>
		
		<script type='text/javascript'>
			function check() {
				var name = $('input[name=name]').attr('value');
				var pwd = $('input[name=pwd]').attr('value');
				
				if(name == "") {
					alert("请输入用户名");
					$('input[name=name]').focus();
					return false;
				}
				if(pwd == "") {
					alert("请输入密码");
					$('input[name=pwd]').focus();
					return false;
				}
				
				$.post('checkLogin.php', 
					{
						type: "login",
						name: name,
						pwd: pwd
					},
					function(data, status) {
						if(status == 'success') {
							sub = (trimStr(data)).split(',');
							if(sub[0] == 'noUser') {
								alert('用户不存在！！');
							} else if(sub[0] == 'pwdError'){
								alert('密码错误！！');
							} else {
								location.href = 'index.php';
							}
						}
					});
			}
		</script>
	</body>
</html>